package com.longrise.co.ui.carlife.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.co.R;
import com.longrise.co.ui.carlife.model.NewsBean;
import com.ly.common.commonutils.ImageLoaderUtils;
import com.ly.common.commonutils.StringUtils;

import java.util.List;


/**
 * Created by admin on 2017/2/4.
 */

public class NewsAdapter extends BaseQuickAdapter<NewsBean.ListBean> {
    private Context mContext;

    public NewsAdapter(List<NewsBean.ListBean> listData, Context context) {
        super(R.layout.item_car_life, listData);
        mContext = context;

    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, NewsBean.ListBean bean) {
        baseViewHolder.setText(R.id.item_car_life_title, bean.getTitle())
                      .setText(R.id.item_car_life_time, bean.getPublishtime());
        ImageView iv = baseViewHolder.getView(R.id.item_car_life_iv);
        if(!StringUtils.isEmpty(bean.getImgtitle())) {
            ImageLoaderUtils.displayWithDefault(mContext, iv , bean.getImgtitle(), R.drawable.test_car_life);
        }
    }
}
